/*
 * @Author: 悦者生存 1002783067@qq.com
 * @Date: 2023-02-26 19:04:58
 * @LastEditors: 悦者生存 1002783067@qq.com
 * @LastEditTime: 2023-10-29 19:47:30
 * @FilePath: /koa2-ts-template/src/server/mysql/pool.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// src/server/mysql/pool.ts
const Sequelize = require('sequelize');
const UserModel = require('../models/user');

// Option 1: Passing parameters separately
const sequelize = new Sequelize('admin', 'root', '123456', {
  host: 'localhost',
  dialect: 'mysql',
  define: {
    timestamps: false,
    paranoid: true,
    underscored: true,
  },
});

const User = UserModel(sequelize);
const db = {
  User,
};

sequelize.sync().then(() => {
  console.log('数据库同步成功');
});

export default db;
